<div id="network-supply-custom-bar2" style="height: 100%">

</div>

<script type="text/javascript">
    $(function () {
        loadbar2("","");
        $("select#prjId").change(function(){
            document.getElementById("loading").style.display="";
            setoption2();
            loadbar2($("#prjId").val(),"");
        });
        $("select#primarySales").change(function(){
            document.getElementById("loading").style.display="";
            loadbar2($("#prjId").val(),$("#primarySales").val());
        });
    });
    function setoption2() {
        var center=$("#prjId").val();
        $.ajax({
            url: "#springUrl('/network/supply/custom/option2')",
            data: {"center": center},
            type: "POST",
            success: function (text) {
                var d = JSON.parse(text);
                if (d.success && d.data) {
                    $("#primarySales").empty();
                    var options="<option value=''>"+"请选择销售渠道"+"</option>";
                    $("#primarySales").append(options);
                    for(var i=0;i<d.data.option2.length;i++){
                        var primarySales=d.data.option2[i].primarySales;
                        var options="<option value='"+primarySales+"'>"+primarySales+"</option>";
                        $("#primarySales").append(options);
                    }
                }
            }
        })
    }
    function loadbar2(center,primarySales) {
        document.getElementById("loading").style.display="";
        $.ajax({
            url: "#springUrl('/network/supply/custom/bar2')",
            data: {"center": center,"primarySales":primarySales},
            type: "POST",
            success: function (text) {
                var d = JSON.parse(text);
                if (d.success && d.data) {
                    var myChart = echarts.init(document.getElementById('network-supply-custom-bar2'), 'macarons');
                    option = {
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#999'
                                }
                            }
                        },
                        toolbox: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                crossStyle: {
                                    color: '#998492'
                                }
                            },
                        },
                        grid: {
                            left: '3%',
                            right: '8%',
                            bottom: '15%',
                            top:'10%',
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: 'category',
                                data: d.data.data1,
                                axisLabel: {
                                    textStyle:{
                                        color:"#595959"
                                    }
                                },
                                axisLine: {
                                    show: false
                                },
                                axisTick: {
                                    show: false
                                },
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value',
                                name: '订单量',
                                axisLine: {
                                    show: false
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLabel: {
                                    formatter: function(value){
                                        var var1=value*1;
                                        return var1;
                                    },
                                    textStyle:{
                                        color:"#595959"
                                    }
                                },
                                splitLine:{
                                    show:true
                                },
                                splitArea: {
                                    show:true,
                                    areaStyle: {
                                        color: ['rgba(0,0,0,0)', 'rgba(0,0,0,0)']
                                    }
                                },
                            },
                            {
                                type: 'value',
                                name: '频次',
                                axisLine: {
                                    show: false
                                },
                                axisTick: {
                                    show: false
                                },
                                axisLabel: {
                                    formatter: function(value){
                                        var var1=value*1;
                                        return var1;
                                    },
                                    textStyle:{
                                        color:"#595959"
                                    }
                                },
                                splitLine:{
                                    show:false
                                },
                                splitArea: {
                                    show: true,
                                    areaStyle: {
                                        color: ['rgba(0,0,0,0)', 'rgba(0,0,0,0)']
                                    }
                                },
                            }
                        ],
                        series: [
                            {
                                name:'订单量',
                                type:'bar',
                                data:d.data.data2,
                                barWidth:20,
                                itemStyle: {
                                    normal: {
                                        //好，这里就是重头戏了，定义一个list，然后根据所以取得不同的值，这样就实现了，
                                        color: '#0fa99d'
                                        },
                                        //以下为是否显示，显示位置和显示格式的设置了
                                    }
                            },
                            {
                                name:'频次',
                                type:'line',
                                yAxisIndex: 1,
                                data:d.data.data3,
                                itemStyle : {
                                    normal: {
                                        color: '#4472c4',
                                    }
                                },
                            }
                        ]
                    };
                    myChart.setOption(option);
                    document.getElementById("loading").style.display="none";
                }else{
                    document.getElementById("loading").style.display="none";
                    var div1="<div   type='text' style='padding-top:15%' class=' text-center '>"+d.message+"</div>";
                    $("#network-supply-custom-bar2").empty();
                    $("#network-supply-custom-bar2").prepend(div1);
                }
            }
        });
    }

</script>